<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/js/boxy/js/jquery.boxy.js"></script>
<link href="/js/boxy/css/boxy.css" media="screen" rel="stylesheet" type="text/css" >  
<script type="text/javascript">
    $(function(){
        window.alert = Boxy.alert;
        window.confirm = Boxy.confirm;
    });
</script>
<div class="admin_nrtop">
    <div class="ad_search">
        <form action=""  method="get" style="margin:0px" id="form1">
            <div class="search">
                <div class="soubox">
                    <input type="text" id="quick" name="quick" value="<?php echo $this->quick ? $this->quick : ""; ?>" placeholder="输入任务名称/任务描述等"/>
                    <input type="hidden" id="starttime" name="starttime" value="<?php echo $this->starttime ? $this->starttime : ""; ?>"/>
                    <input type="hidden" id="endtime" name="endtime" value="<?php echo $this->endtime ? $this->endtime : ""; ?>" />
                    <input type="hidden" id="pagesize" name="pagesize" value="<?php echo $this->pagesize ? $this->pagesize : 10; ?>" />
                    <input type="hidden" id="jobType" name="jobType" value="<?php echo $this->jobType === "" ? "" : $this->jobType; ?>" />
                    <input type="hidden" id="jobExecute" name="jobExecute" value="<?php echo $this->jobExecute === "" ? "" : $this->jobExecute; ?>" />
                    <input type="hidden" id="jobDisable" name="jobDisable" value="<?php echo $this->jobDisable === "" ? "" : $this->jobDisable; ?>" />
                    <input type="hidden" id="lastStatus" name="lastStatus" value="<?php echo $this->lastStatus === "" ? "" : $this->lastStatus; ?>" />
                    <a href="javascript:$('#form1').submit();"><span>搜索</span></a>
                </div>
            </div>
            <div class="timebox">
                <div class="ad_time">
                    <div class="timezdy">
                        <div class="timeselect2">
                            <span>创建时间</span>
                        </div>
                    </div>
                    <div class="timefw">
                        <div class="time">
                            <div class="timeselect"  id="stime">
                                <span id="stimeval"><?php echo $this->starttime ? $this->starttime : date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 90, date("Y"))); ?></span><i></i>
                            </div>
                            <div class="timeslelctbox">
                            </div>
                        </div>
                        <div class="timezhi">
                            <span>至</span>
                        </div>
                        <div class="time" >
                            <div class="timeselect" id="etime">
                                <span id="etimeval"><?php echo $this->endtime ? $this->endtime : date("Y-m-d"); ?></span><i></i>
                            </div>
                            <div class="timeslelctbox">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="timeok">
                    <a href="javascript:$('#form1').submit();">确定</a>
                </div>
            </div>
            <div class="xianshi">
                <label>显示：</label>
                <ul>
                    <li <?php echo $this->pagesize ? ($this->pagesize == 10 ? 'class="xson"' : "") : 'class="xson"'; ?>><a href="javascript:void(0)" class="setpagesize" name="10">10</a></li>
                    <li <?php echo $this->pagesize ? ($this->pagesize == 20 ? 'class="xson"' : "") : ""; ?>><a href="javascript:void(0)" class="setpagesize" name="20">20</a></li>
                    <li <?php echo $this->pagesize ? ($this->pagesize == 30 ? 'class="xson"' : "") : ""; ?>><a href="javascript:void(0)" class="setpagesize" name="30">30</a></li>
                </ul>
            </div>
        </form>
    </div>
</div>
<div  class="biaoge">
    <div class="biaotbody">
        <table>
            <tr>
                <th class="li5">
                    <div class="lileft">创建时间</div>
                </th>
                <th class="li3">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>任务类型</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php  foreach ($this->jobTypeAll as $key => $jobTypeVal) { ?>
                                    <li><a href="javascript:void(0)" class="setjobType" name="<?php echo $key;?>"><?php echo $jobTypeVal; ?></a></li>
                                <?php } ?>
                            </ul>
                        </div>
                    </div>
                </th>
                <th class="li9">
                    <div class="lileft">任务名称</div>
                </th>
                <th class="li15" >
                    <div class="lileft">任务描述</div>
                </th>
                <th class="li5">
                    <div class="lijz">执行次数</div>
                </th>
                <th class="li5" >
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>执行类型</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php if ($this->jobExecuteAll) {
                                    foreach ($this->jobExecuteAll as $key => $jobExecuteVal) { ?>
                                    <li><a href="javascript:void(0)" class="setjobExecute" name="<?php echo $key; ?>"><?php echo $jobExecuteVal; ?></a></li>
                                <?php } } ?>
                            </ul>
                        </div>
                    </div>
                </th>
                <th class="li5">
                    <div class="biaoxiala">
                        <div class="lixiala">
                            <span>是否启用</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php if ($this->jobDisableAll) {
                                    foreach ($this->jobDisableAll as $key => $jobDisableVal) { ?>
                                    <li><a href="javascript:void(0)" class="setjobDisable" name="<?php echo $key; ?>"><?php echo $jobDisableVal; ?></a></li>
                                <?php } } ?>
                            </ul>
                        </div>
                    </div>
                </th>
                <th class="li5">
                   <div class="biaoxiala">
                        <div class="lixiala">
                            <span>最后执行状态</span>
                            <i></i>
                        </div>
                        <div class="biaoxllb" style="display:none;">
                            <ul>
                                <?php if ($this->lastStatusAll) {
                                    foreach ($this->lastStatusAll as $key => $lastStatusVal) { ?>
                                    <li><a href="javascript:void(0)" class="setlastStatus" name="<?php echo $key; ?>"><?php echo $lastStatusVal; ?></a></li>
                                <?php } } ?>
                            </ul>
                        </div>
                    </div>
                </th>
                <th class="li5">
                   <div class="lileft">最后执行时间</div>
                </th>
                <th class="li505"><div class="lijz">操作</div></th>
            </tr>
        </table>
    </div>
    <?php if ( $this->jobType || $this->jobExecute || $this->jobDisable || ($this->lastStatus !== "" && $this->lastStatus !== null)) { ?>
        <div class="xzinfo">
            <ul>
            <?php if ($this->jobType) { ?><li><div class="xzinfobox"><span><?php echo $this->jobTypeAll["$this->jobType"];?></span><a href="javascript:void(0)" title="撤销" class="removeset" name="jobType"><i>撤销</i></a></div></li><?php } ?>
            <?php if ($this->jobExecute) { ?><li><div class="xzinfobox"><span><?php echo $this->jobExecuteAll["$this->jobExecute"];?></span><a href="javascript:void(0)" title="撤销" class="removeset" name="jobExecute"><i>撤销</i></a></div></li><?php } ?>
            <?php if ($this->jobDisable) { ?><li><div class="xzinfobox"><span><?php echo $this->jobDisableAll["$this->jobDisable"];?></span><a href="javascript:void(0)" title="撤销" class="removeset" name="jobDisable"><i>撤销</i></a></div></li><?php } ?>
            <?php if ($this->lastStatus === "" && $this->lastStatus !== null) {  } else { ?><li><div class="xzinfobox"><span><?php echo $this->lastStatusAll["$this->lastStatus"]; ?></span><a href="javascript:void(0)" title="撤销" class="removeset" name="lastStatus"><i>撤销</i></a></div></li><?php } ?>
            </ul>
        </div>
    <?php } ?>
    <div class="table" style="margin-top: 0px;">
        <table>
            <?php if ($this->jobList) {
                foreach ($this->jobList as $key => $Item) { ?>
                <tr style="height: 50px;">
                    <td class="li5"><div class="lileft"><?php echo $Item->DateCreated;?></div></td>
                    <td class="li3"><div class="lileft"><?php echo $Item->TypeName;?></div></td>
                    <td class="li9"><div class="lileft"><a href="/admini/autotask/jobdetail/id/<?php echo $Item->Id;?>" class="indexa"><?php echo $Item->Name;?></a></div></td>
                    <td class="li15"><div class="lileft"><?php echo $Item->Description;?></div></td>
                    <td class="li5"><div class="lijz"><?php echo $Item->count?$Item->count:0;?></div></td>
                    <td class="li5"><div class="lileft"><?php echo $Item->ExecuteName;?></div></td>
                    <td class="li5"><div class="lileft"><?php echo $Item->DisableName;?></div></td>
                    <td class="li5"><div class="lileft"><?php echo $Item->LastStatusName;?></div></td>
                    <td class="li5"><div class="lileft"><?php echo $Item->dateLast?$Item->dateLast:"暂无";?></div></td>
                    <td class="li505"><div class="lileft">
                        <div class="lixlnav">
                            <a class="xlnavxq" href="/admini/autotask/jobdetail/id/<?php echo $Item->id;?>" >详情</a>
                            <div class="xlnavlistbox" >
                                <a class="xlnavsj" href="javascript:void(0)"><i></i></a>
                                <div class="xlnavlist" style="display:none;">
                                    <ul>
                                        <li><a href="/admini/autotask/jobdetail/actype/1/id/<?php echo $Item->id;?>" >修改</a></li>
                                        <li><a href="javascript:void(0)" class="executeJob" name='<?php echo $Item->id;?>'>执行</a></li>
                                        <li><a href="javascript:void(0)" class="delJob" name='<?php echo $Item->id;?>' >删除</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div></td>
                </tr>
            <?php }
                } else {
                    echo '<div class="tablebox">暂时无数据</div>';
                } ?>
        </table>
    </div>
</div>
<div class="toolbar">
    <div class="qunx">
        <ul>
            <li><a class="anvbotton" href="/admini/autotask/addjob" id="printOut" name="printOut"><span>添加新任务</span></a></li>
        </ul>
    </div>
<?php
echo $this->partial('paging.phtml', array("pages" => $this->financialAll, "pamas" => "quick=$this->quick&starttime=$this->starttime&endtime=$this->endtime&pagesize=$this->pagesize&jobType=$this->jobType&jobExecute=$this->jobExecute&jobDisable=$this->jobDisable&lastStatus=$this->lastStatus"));
?>
</div>   
<script>
    $(function(){
        $('.soubox label').click(function() {
            $(this).parent().find('input').focus();
        });
        $(".timezdy").click(function() {
            $(".timezdy .timeselect2").attr("class", "timeselect2 timeon");
            $(".timeslelct_xl").show();
        });
        $(".timezdy").mouseleave(function() {
            $(".timeselect2").attr("class", "timeselect2");
            $(".timeslelct_xl").hide();
        });
        $("#stime").click(function() {
            $(this).attr("class", "timeselect t_on");
            WdatePicker({el: 'stimeval', vel: 'starttime', onpicked: function() {
                    $("#stime,#etime").attr("class", "timeselect");
                }});
        });
        $("#etime").click(function() {
            $(this).attr("class", "timeselect t_on");
            WdatePicker({el: 'etimeval', vel: 'endtime', onpicked: function() {
                    $("#stime,#etime").attr("class", "timeselect");
                }});
        });

        $(".lixiala").click(function() {
            $(".lixiala").attr("class", "lixiala");
            $(".lixiala").next("div").hide();

            $(this).attr("class", "lixiala bton");
            $(this).next("div").show();
        });
        $(document).bind("click", function(e) {
            var target = $(e.target);
            if (target.closest(".biaoxiala").length == 0) {
                $(".lixiala").attr("class", "lixiala");
                $(".lixiala").next("div").hide();
            }
            if (target.closest("#stime").length == 0) {
                $("#stime").attr("class", "timeselect");
            }
            if (target.closest("#etime").length == 0) {
                $("#etime").attr("class", "timeselect");
            }
        });
        $('.countryzm a').each(function(index, item) {
            $(item).click(function() {
                $('.countryzm li.zmon').removeClass('zmon');
                $(this).parent().addClass('zmon');
                $('#countryTab ul').hide();
                $('#countryTab ul').eq(index).show();
                return false;
            });
        });
        $('.countrylist a').bind('click', function() {
            $(".soubox #cityid").val($(this).attr('cid'));
            $('#form1').submit();
        });

        $(".xlnavsj").live("mousemove", function() {
            $(this).next("div").show();
        });
        $(".lixlnav").mouseleave(function() {
            $(".xlnavsj").next("div").hide();
        });
        $(".setpagesize").click(function(){
            var name = $(this).attr("name");
            $("#form1 #pagesize").val(name);
            $("#form1").submit();
        });
        $(".setjobType").click(function(){
            var name = $(this).attr("name");
            $("#form1 #jobType").val(name);
            $("#form1").submit();
        });
        $(".setjobExecute").click(function(){
            var name = $(this).attr("name");
            $("#form1 #jobExecute").val(name);
            $("#form1").submit();
        });
        $(".setjobDisable").click(function(){
            var name = $(this).attr("name");
            $("#form1 #jobDisable").val(name);
            $("#form1").submit();
        });
        $(".setlastStatus").click(function(){
            var name = $(this).attr("name");
            $("#form1 #lastStatus").val(name);
            $("#form1").submit();
        });
        $(".removeset").click(function(){
            var name = $(this).attr("name");
            $("#form1 #"+name).val("");
            $("#form1").submit();
        });
        $(".executeJob").click(function(){
            var id = $(this).attr("name");
            $(this).text("执行中");
            confirm("您确认该任务现需要手工执行下？",function(){
                $.post("/admini/job/indexone",{"id":id},function(data){
                   if(data == 1){
                       alert("执行成功！");
                       location.reload();
                   } else {
                       alert("出现未知错误！");
                   }
                });
            });
        });
        $(".delJob").click(function(){
            var id = $(this).attr("name");
            confirm("您确认删除该任务？",function(){
                $.post("/admini/autotask/deljob",{"id":id},function(data){
                   if(data == 1){
                       alert("删除成功！");
                       location.reload();
                   } else {
                       alert("出现未知错误！");
                   }
                });
            });
        });
    });
</script>
